﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Infragistics.Windows.TilePanel;
using Microsoft.Practices.Composite.Presentation.Regions;
using UIComposition.Infrastructure;
using System.Configuration;
using FXSStation.Modules.SharedInfrastructureModule.Extentions.TileView;

namespace FXSStation.Shell
{
    /// <summary>
    /// Interaction logic for Shell.xaml
    /// </summary>
    public partial class Shell : Window, IShellView
    {
        public Shell()
        {
            InitializeComponent();
            ShowView();
        }

        #region IShellView Members

        public void ShowView()
        {
            this.Show();
        }

        #endregion

        private void tilePanel_Loaded(object sender, RoutedEventArgs e)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            TileViewConfigurationSection section = (TileViewConfigurationSection)config.GetSection("TileViewSettings");
            foreach (TileViewConfigurationElement element in section.TileViews)
            {
                WorkspaceItem item = new WorkspaceItem();
                item.Height = element.Height;
                item.Width = element.Width;
                Canvas.SetLeft(item, element.Left);
                Canvas.SetTop(item, element.Top);
                RegionManager.SetRegionName(item, element.RegionName);

                tilePanel.Items.Add(item);
            }
        }
    }
}
